﻿Imports System.Data.SqlClient

Module PedidosAutomaticos

    Dim variableconex As New SqlConnection(My.Settings.CITRA_ERPConnectionString)



    Public Sub ConsultarExistencias(Almacen As Integer)


        Dim DA As New SqlDataAdapter("select idproducto from Existencia where idAlmacen=" & Almacen, variableconex)
        Dim dt As New DataTable

        Dim ArrayProductos As New ArrayList
        DA.Fill(dt)

        For Each dr As DataRow In dt.Rows
            ArrayProductos.Add(dr(0).ToString())
        Next

        Dim DS As New DataSet

        For Each producto As String In ArrayProductos


            MsgBox(producto)

            Dim dos As New SqlDataAdapter("EXEC calcularExistencia @producto = " & producto & ", @Almacen=" & Almacen, variableconex)
            dos.Fill(DS)



        Next

        frmExistencias.DataGridView1.DataSource = DS.Tables(0)

    End Sub
   



End Module
